1770F - Koxia and Sequence - CodeForces Solution


bitmasks combinatorics dp math number theory *3100

Please click on ads to support us..

C++ Code:

#include <bits/stdc++.h>
#define int long long
using namespace std;

void solve(int tcId) {
    int n, x, y;
    cin >> n >> x >> y;

    if (n % 2 == 0) {
        cout << "0\n";
        return;
    }

    int ans = 0;

    for (int msk = y; msk; msk = (msk - 1) & y) {
        for (int bit = 0; bit < 20; bit++) {
            if (msk & ((int)1 << bit)) {
                if (((x - ((int)1 << bit)) & (n * msk - ((int)1 << bit))) == (x - ((int)1 << bit)))
                    ans ^= (int)1 << bit;
            }
        }
    }

    cout << ans << '\n';
}

signed main() {
    bool multi = false;
    if (!multi) {
        solve(42);
    } else {
        int t;
        cin >> t;
        while (t--)
            solve(t);
    }
}


Comments

Submit
0 Comments
More Questions

1144A - Diverse Strings
1553B - Reverse String
1073A - Diverse Substring
630N - Forecast
312B - Archer
34D - Road Map
630I - Parking Lot
160B - Unlucky Ticket
371B - Fox Dividing Cheese
584B - Kolya and Tanya
137B - Permutation
550C - Divisibility by Eight
5A - Chat Servers Outgoing Traffic
615A - Bulbs
5B - Center Alignment
549A - Face Detection
535B - Tavas and SaDDas
722C - Destroying Array
366A - Dima and Guards
716B - Complete the Word
1461C - Random Events
1627A - Not Shading
141B - Hopscotch
47B - Coins
1466C - Canine poetry
74A - Room Leader
1333D - Challenges in school №41
1475B - New Year's Number
461A - Appleman and Toastman
320B - Ping-Pong (Easy Version)